#!/bin/sh

case "$1" in 
 start) 
  case "$2" in 
   test | demo) 
    java -Xms256m -Xmx256m -Dspring.profiles.active="$2" -Dlog.level=info -Dlog.level.cass=trace -jar ./stastic-service.jar >/dev/null 2>&1 &
   ;; 
   prod) 
    java -Xms256m -Xmx256m -Dspring.profiles.active="$2" -Dlog.level=warn -Dlog.level.cass=info -jar ./stastic-service.jar >/dev/null 2>&1 &
   ;; 
   *) 
    printf 'append active profile: %s {test|demo|prod}\n' "$prog"
    exit 1
   ;;
  esac
 ;; 
 stop) 
  ps -ef|grep stastic-service.jar|awk '{print $2}'|while read pid
  do
    kill -15 $pid
  done
 ;;
 *) 
  printf 'Usage: %s {start|stop}\n' "$prog"
  exit 1
 ;;
esac
